package org.adit.spring.hibernate.parser;

import org.adit.spring.hibernate.parser.entity.Load;

import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

public class LoadConverter implements Converter {

    public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
        Load load = (Load) value;
        writer.addAttribute("ind", load.getInd());
        writer.setValue(load.getLoad());
    }

    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
        Load load = new Load();
        load.setLoad(reader.getValue());
        load.setInd(reader.getAttribute("ind"));
        return load;
    }

    public boolean canConvert(Class clazz) {
        return clazz.equals(Load.class);
    }



}